package agrep4me;

import java.io.IOException;
import java.io.InputStreamReader;

public class Agrep {

	private Table zyva(Auto a, int nerrs, States ex) {
		if (a.someEpsilon()) {
			a.sharpOut();
			return new Table3(a, nerrs, ex);
		} else if (a.someSharp()) {
			return new Table2(a, nerrs, ex);
		} else {
			return new Table1(a, nerrs, ex);
		}
	}

	public void match(String pat, int error, InputStreamReader isr)
			throws IOException {
		Auto a = new Auto(pat);
		States ex = States.setCard(a.fstate + 1);
		Table t = zyva(a, error, ex);

		Fichier f = new Fichier(isr);
		t.match(f, error);

		System.out.println("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + t.alphaSize());

		f.close();
	}
}
